var a = getApp();

Page({
    data: {
        info: {},
        goodsList: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getData();
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.new-retail.frontend.index.index");
        a._postNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    info: e.data
                }), wx.setNavigationBarTitle({
                    title: e.data.project_name
                }), t.getGood()) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                wx.hideLoading(), console.log(a.msg);
            }
        });
    },
    getGood: function() {
        var t = this, e = a.getNetAddresss("plugin.new-retail.frontend.index.goodsList");
        a._postNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    goodsList: e.data.data,
                    isLoadMore: !0,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                wx.hideLoading(), console.log(a.msg);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.new-retail.frontend.index.goodsList");
            a._postNetWork({
                url: e,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var o = e.data.data, n = t.data.goodsList.concat(o);
                        t.setData({
                            goodsList: n
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    gotoUrl: function(a) {
        var t = a.currentTarget.dataset.tag;
        0 == t ? wx.navigateTo({
            url: "/packageH/newRetail/newRetailSalesExtension/newRetailSalesExtension"
        }) : 1 == t ? wx.navigateTo({
            url: "/packageH/newRetail/newRetailSearch/newRetailSearch?t=2"
        }) : 2 == t ? wx.navigateTo({
            url: "/packageH/newRetail/newRetailSearch/newRetailSearch?t=3"
        }) : 3 == t ? wx.navigateTo({
            url: "/packageH/newRetail/newRetailInventory/newRetailInventory"
        }) : 4 == t ? wx.navigateTo({
            url: "/packageH/newRetail/newRetailSalesRecord/newRetailSalesRecord"
        }) : 5 == t && wx.navigateTo({
            url: "/packageA/member/myOrder_v2/myOrder_v2?status=0&orderType=newRetail"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});